package com.google.gwt.gwtpages.client.page;

import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.gwtpages.client.GotoPageCommand;
import com.google.gwt.gwtpages.client.PageRequestSession;
import com.google.gwt.gwtpages.client.page.parameters.PageParameters;
import com.google.gwt.user.client.ui.RootPanel;

public class DefaultPageLoadingHandler implements PageEventHandler {

	public void onAfterPageEnter(LoadedPageContainer pageLoadResult,
			PageParameters parameters, GotoPageCommand command) {
	}

	public void onPageEnterSuccess(LoadedPageContainer pageLoadResult,
			PageParameters parameters, GotoPageCommand command) {
		RootPanel.getBodyElement().getStyle().setCursor(Cursor.DEFAULT);
	}

	public void onPageEnterFailure(LoadedPageContainer pageLoadResult,
			PageParameters parameters, GotoPageCommand command) {
		RootPanel.getBodyElement().getStyle().setCursor(Cursor.DEFAULT);
	}

	public void onPageRequest(String pageToken, String historyToken,
			PageRequestSession session) {
		RootPanel.getBodyElement().getStyle().setCursor(Cursor.WAIT);
	}

	public void onBeforePageEnter(LoadedPageContainer pageLoadResult,
			PageParameters parameters, GotoPageCommand command) {
	}

	public void onPageLoaded(LoadedPageContainer result) {
	}

	public void onPageNotFound(String historyToken) {
		RootPanel.getBodyElement().getStyle().setCursor(Cursor.DEFAULT);
	}

	public void onPageLoadFailure(String historyToken, Throwable cause) {
		RootPanel.getBodyElement().getStyle().setCursor(Cursor.DEFAULT);
	}

	public void onPageWaitForAsync(LoadedPageContainer loadedPageContainer,
			PageParameters parameters, GotoPageCommand command) {
	}
}